<template>
	<view>
		<view style="font-size: 12px;color: #666;">注：pc不支持下拉刷新</view>
		<view class="text" v-for="(num,index) in data" :key="index">当前排在第几-{{num}}</view>
		<view class="uni-load-more" style="text-align: center;" v-if="showLoadMore">{{loadMoreText}}</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				data:[],
				loadMoreText:"加载中...",
				showLoadMore:false,
				max:0
			}
		},
		onLoad(){//页面加载时
			this.initData();
		},
		onUnload(){//页面将要消杀时
			
		},
		onReachBottom(){//页面上拉加载事件
			console.log('onReachBottom');
			debugger
			if(this.max>=100){
				this.loadMoreText = "没有更多数据了"
				return;
			}
			this.showLoadMore = true;
			setTimeout(()=>{
				this.setListData();
			},300);

		},
		onPullDownRefresh(){//页面下拉刷新事件
			this.initData();
		},
		methods:{
			initData(){
				setTimeout(() => {
					this.max = 0;
					this.data = [];
					let data = [];
					this.max += 20;
					for (var i = this.max - 19; i < this.max + 1; i++) {
						data.push(i)
					}
					this.data = this.data.concat(data);
					uni.stopPullDownRefresh();
				}, 300);
			},
			setListData(){
				let data = [];
				this.max += 10;
				for (var i = this.max - 9; i < this.max + 1; i++) {
					data.push(i)
				}
				this.data = this.data.concat(data);
			}
		}
	}
</script>

<style>
	.text {
		margin: 16rpx 0;
		width:100%;
		background-color: #fff;
		height: 120rpx;
		line-height: 120rpx;
		text-align: center;
		color: #555;
		border-radius: 8rpx;
	}
</style>